<?php
/**
 * 逻辑基础理类
 * 
 * Copyright (c) 2014~2019 https://desion.net All rights reserved.
 * Author: 阿林 QQ:120867629 <linhong00@gmail.com>
 */
declare (strict_types = 1);
namespace dsphp;
use dsphp\Db;
//use dsphp\helper\Arrays;
use dsphp\logic\Result;

abstract class Logic
{
    use Result;

    protected $app;

    
    /**
     * 构造函数
     *
     * @param App $app     自动加载
     * @param array $vars  初始化参数
     */
    public function __construct(App $app, array $vars = [])
    {
        $this->app = $app;
        $this->initialize($vars);
    }

    /**
     * 析构函数
     */
    public function __destruct()
    {
        //
    }

    /**
     * 初始化
     */
    protected function initialize($vars){}

    /**
     * 实例数据模型
     *
     * @param string  $name  模块名称(表名)
     * @param string  $suffix 暂停为多表计算参数
     * @return model
     */
    public function db(string $name, $suffix = null)
    {
        $name = $this->app->parseClass('model', $name);
        return $this->app->make($name, [$suffix]);
    }
}
